﻿/*
 * Use 646, 556 for 640 x 480 resolution
 * Use 326, 316 for 320 x 240 resolution
 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace _3D_Processor
{
    public partial class PreviewWindow : Form
    {
        public PreviewWindow()
        {
            InitializeComponent();
            AlwaysOnTop.Checked = Properties.Settings.Default.PreviewTopmost;
            SizeMode.SelectedIndex = Properties.Settings.Default.SizeMode;
        }

        public MainForm MainAppForm;

        private void AlwaysOnTop_CheckedChanged(object sender, EventArgs e)
        {
            bool IsTopMost = AlwaysOnTop.Checked;
            this.TopMost = IsTopMost;
            Properties.Settings.Default.PreviewTopmost = IsTopMost;
            Properties.Settings.Default.Save();
        }

        private void SizeMode_SelectedIndexChanged(object sender, EventArgs e)
        {
            int sizeMode = SizeMode.SelectedIndex;

            switch (sizeMode)
            {
                case 0:
                    Width = 326;
                    Height = 316;
                    break;
                case 1:
                    Width = 646;
                    Height = 556;
                    break;
                default:
                    Width = 326;
                    Height = 316;
                    sizeMode = 0;
                    break;
            }
            Properties.Settings.Default.SizeMode = sizeMode;
            Properties.Settings.Default.Save();
        }

        private void PreviewWindow_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (CountDownPan.Visible)
            {
                System.Windows.Forms.DialogResult DR = MessageBox.Show("Capturing timer will be terminated. Do you want to continue?", "Confirm", MessageBoxButtons.YesNo);
                if (DR == System.Windows.Forms.DialogResult.No) e.Cancel = true;

            }
            if (MainAppForm.RecordingStatus != ApplicationStatus.RecordingStopped)
            {
                System.Windows.Forms.DialogResult DR = MessageBox.Show("Video recording will be terminated. Do you want to continue?", "Confirm", MessageBoxButtons.YesNo);
                if (DR == System.Windows.Forms.DialogResult.No) e.Cancel = true;
            }
        }

        private void PreviewWindow_FormClosed(object sender, FormClosedEventArgs e)
        {
            MainAppForm.PreviewWindowClosed();
        }

    }
}
